﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AwesomeEnginePC.Extras
{
    public static class Extensions
    {
        public static bool IsBetween<T>(this T source, T min, T max, bool minInclusive = true, bool maxInclusive = true) where T : IComparable
        {
            bool minCheck = false;
            bool maxCheck = false;

            if (minInclusive)
                minCheck = source.CompareTo(min) >= 0;
            else
                minCheck = source.CompareTo(min) > 0;

            if (maxInclusive)
                maxCheck = source.CompareTo(max) <= 0;
            else
                maxCheck = source.CompareTo(max) < 0;

            return minCheck && maxCheck;
        }


    }
}
